<?php
//require('functions.php');
if(isset($_POST['submit'])){
	require('clases/cliente.class.php');

	$id = normalize(htmlspecialchars(trim($_POST['id'])));
	$userName = normalize(htmlspecialchars(trim($_POST['userName'])));
	$imageURL = normalize(htmlspecialchars(trim($_POST['imageURL'])));
	$text = normalize(htmlspecialchars(trim($_POST['text'])));
	$polarity = normalize(htmlspecialchars(trim($_POST['polarity'])));

	$objCliente=new Cliente;
        if ( mysql_fetch_row($objCliente->mostrar_cliente($id)) == true){
            echo 'Este twitt ya existe';
        }
	else if ( $objCliente->insertar(array($id,$userName,$imageURL,$text,$polarity)) == true){
                    echo 'Datos guardados';
             }else{
                    echo 'Se produjo un error. Intente nuevamente';
             }
}else{echo 'error de paso de parametros';}

function normalize($text) {
    $text = utf8_decode($text);
    return $text;
}
?>